package tx.bj12320.dao;

import javacommon.base.BaseHibernateDao;

import org.springframework.stereotype.Repository;

import tx.bj12320.model.Resource;
import tx.bj12320.vo.query.ResourceQuery;
import cn.org.rapid_framework.page.Page;

@Repository
public class ResourceDao extends BaseHibernateDao<Resource,java.lang.Long>{

	public Class getEntityClass() {
		return Resource.class;
	}

	public Page findPage(ResourceQuery query) {
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接
        // [column] 为PageRequest的属性
		String sql = "select t from Resource t where 1=1 "
			  	+ "/~ and t.userInfoId = {userInfoId} ~/"
			  	+ "/~ and t.resourceName like '%[resourceName]%' ~/"
			  	+ "/~ and t.resourceType = {resourceType} ~/"
			  	+ "/~ and t.resourceSize = {resourceSize} ~/"
			  	+ "/~ and t.resourceFile = {resourceFile} ~/"
				+ "/~ and t.resourceIssueDate >= {resourceIssueDateBegin} ~/"
				+ "/~ and t.resourceIssueDate <= {resourceIssueDateEnd} ~/"
				+ "/~ and t.resourceType < {isResourceType} ~/"
				+ "/~ order by [sortColumns] ~/";



		return pageQuery(sql,query);
	}


}
